package com.jet.core.exception;

import com.jet.core.result.ResultCode;
import com.jet.core.result.ResultJson;
import lombok.Getter;

/**
 * 自定义异常
 */
@Getter
public class CustomException extends RuntimeException {

    private final ResultJson<?> resultJson;

    public CustomException() {
        this.resultJson=ResultJson.failure();
    }

    public CustomException(ResultCode code) {
        this.resultJson = ResultJson.failure(code);
    }

    public CustomException(String msg) {
        this.resultJson = ResultJson.failure(ResultCode.SYSTEM_ERROR.getCode(), msg);
    }

    public CustomException(ResultCode code, String msg) {
        this.resultJson = ResultJson.failure(code.getCode(), msg);
    }

    public CustomException(int code, String msg, Object data) {
        this.resultJson = ResultJson.failure(code, msg, data);
    }

    public CustomException(ResultJson<?> resultJson) {
        this.resultJson = resultJson;
    }
}
